package observermode;

import java.util.Observable;
import java.util.Observer;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/19 9:54
 */
public class StudentObserver implements Observer {
    private String name;

    public StudentObserver(String name) {
        this.name = name;
    }

    public void addObservable(Observable observable) {
        observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof Teacher) {
            System.out.println(name + "收到布置的作业" + arg);
        }
    }
}
